<template>
	<div >
		<el-col :span='6'><img :src='picture' style="width: 40%; height: 40%;">
		</el-col>
		
		<el-col :span='18'>
		<h3>{{ id }}{{ name }}</h3>
		<p>{{ description }}</p>
		<span>发布日期 ：2020-03-07 ｜ 浏览次数 ：100 </span>
		
		</el-col>
		
		<router-link v-if="infotype == 0" :to="{ name: 'Info', params: { id: this.id, name: this.name, description: this.description, picture: this.picture }}"><el-button type='success' size='small' style=' margin-left: 70%;'>详情</el-button>
		</router-link>
		
		<el-button v-if='infotype == 1' type='success' size='small' style=' margin-left: 70%;' @click='dialogvisible = true'>详情</el-button>
		<show v-if="infotype == 1" :dialogVisible="dialogvisible" v-on:childByValue="childByValue"
		:name="name"
		:id='id'
		:description='description'
		:picture='picture'></show>
		
		<hr />
	</div>
</template>

<script>
	import show from '../show.vue'
	export default {
		name: 'searchinfo',
		components:{
			show
		},
		data () {
			return {
				dialogvisible: false,
				flags: false
			}
		},
		props:{
			infotype: {
				type: Number,
				default: 0
			},
			id: {
				type: Number,
				default: 0
			},
			name: {
				type: String,
				default: 'name'
			},
			description: {
				type: String,
				default: ''
			},
			picture: {
				type: String,
				default: 'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2931176263,3235139832&fm=26&gp=0.jpg'
			}
		},
		methods:{
			childByValue(flags) {
				this.dialogvisible=flags;
			},
			childclick() {
				// childByValue是在父组件on监听的方法
				// 第二个参数this.flags是需要传的值
				this.$emit('childByValue', this.flags)
			}
		}
	}
</script>

<style>
</style>
